package com.hqu.ms.more;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import br.com.dina.ui.model.ViewItem;
import br.com.dina.ui.widget.UITableView;
import br.com.dina.ui.widget.UITableView.ClickListener;

import com.actionbarsherlock.app.SherlockFragment;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EFragment;
import com.googlecode.androidannotations.annotations.ViewById;
import com.hqu.ms.AboutUsActivity_;
import com.hqu.ms.R;
import com.umeng.fb.UMFeedbackService;


@EFragment(R.layout.ms_more_fragment)
public class MoreFragment extends SherlockFragment implements ClickListener{
	
	@ViewById
	UITableView setting;
	
	@AfterViews
	void afterViewInjected(){
		initTableView();
	}
	
	void initTableView(){
		setting.addBasicItem(getString(R.string.more_feedback_text));
		setting.addBasicItem(getString(R.string.more_about_text));
		addVersionItem();
		setting.setClickListener(this);
		
		setting.commit();
	}

	@Override
	public void onClick(int index) {
		switch (index) {
		case 0:
			feedback();
			break;
		case 1:
			aboutUs();
			break;
			
		default:
			break;
		}
	}
	
	void addVersionItem() {
		View view = LayoutInflater.from(getActivity()).inflate(R.layout.ms_more_version, null);
		ViewItem item = new ViewItem(view);
		item.setClickable(false);
		setting.addViewItem(item);
	}
	
	void feedback() {
		UMFeedbackService.openUmengFeedbackSDK(getActivity());
		getActivity().overridePendingTransition(R.anim.base_slide_right_in, R.anim.base_stay_orig);
	}
	
	void aboutUs(){
		AboutUsActivity_.intent(getActivity()).start();
		getActivity().overridePendingTransition(R.anim.base_slide_right_in, R.anim.base_stay_orig);
	}
	
}
